import 'package:bt_dsp_88/tool/assets.dart';
import 'package:flutter/material.dart';

import '../../model/model.dart';
import 'gain_db_item.dart';

class GaidDbView extends StatefulWidget {
  List<ChannelModel> ch_list;
  void Function(ChannelModel, String) onChange;
  void Function(ChannelModel, String) onChangeForSend;

  GaidDbView(
      {super.key,
      required this.ch_list,
      required this.onChange,
      required this.onChangeForSend});

  @override
  State<GaidDbView> createState() => _GaidDbViewState();
}

class _GaidDbViewState extends State<GaidDbView> {
  @override
  Widget build(BuildContext context) {
    double screenWidth = MediaQuery.of(context).size.width;
    double w = (screenWidth - 5 * 7 - 20).toDouble() / 8.0;
    return SizedBox(
        height: 316 * GlobalConfig.scaleH,
        child: GridView.extent(
          maxCrossAxisExtent: w,
          mainAxisSpacing: 5,
          crossAxisSpacing: 5,
          childAspectRatio: w / 316 / GlobalConfig.scaleH,
          physics: const NeverScrollableScrollPhysics(),
          children: (widget.ch_list).map(($0) {
            return GaidDbItem(
                ch: $0,
                width: w,
                onChange: widget.onChange,
                onChangeForSend: widget.onChangeForSend);
          }).toList(),
        ));
  }
}
